package homework.mid_autumn_festival.collection_exercixe;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;

public class CollectionDemo1 {
    public static void main(String[] args) {
       // Collection c = new HashSet();
        Collection c = new ArrayList();
        c.add("one");
        c.add("two");
        c.add("three");
        c.add("four");
        c.add("five");
        boolean b = c.add("one");
        System.out.println(b);//true ArrayList数组可以添加重复的元素

        //集合重写了Object的toString方法 输出格式如下
        //[元素1.toString,元素2.toString,元素3.toString...]

        System.out.println(c);
        System.out.println("集合的元素个数:"+c.size());//6
        System.out.println("是否为空集:"+c.isEmpty());//false

        c.clear();//清空
        System.out.println("集合元素个数为:"+c.size());//0
        System.out.println("是否为空集:"+c.isEmpty());//true


    }
}
